<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .box {
        width: 200px;
        height: 200px;
        background-color: pink;
        margin: 20px;
        padding: 30px;
      }
    </style>
  </head>
  <body>
    <div class="box" id="box01">
      <h2>mouseout</h2>
      <button>子元素1</button>
      <button>子元素2</button>
    </div>
    <div class="box" id="box02">
      <h2>mouseleave</h2>
      <button>子元素1</button>
      <button>子元素2</button>
    </div>
    <script>
      const box01 = document.querySelector('#box01')
      const box02 = document.querySelector('#box02')
      
      // mouseout/mouseover      鼠标移出/移入
      // box01.addEventListener('mouseout',() => {
      //   console.log('💥mouseout 鼠标移出盒子了');
      // })
      box01.addEventListener('mouseover',() => {
        console.log('💥mouseover 鼠标移入盒子了');
      })
      
      // mouseleave/mouseenter  👍更好用的鼠标移出/移入
      box02.addEventListener('mouseleave',() => {
        console.log('👍mouseleave 鼠标移出盒子了');
      })
      // box02.addEventListener('mouseenter',() => {
      //   console.log('👍mouseenter 鼠标移出盒子了');
      // })
    </script>
  </body>
</html>
